﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Threading.Tasks;

namespace OOSync
{
    /// <summary>
    /// 数据分发总管
    /// </summary>
    public class DispatcherManager : MonoEX.Singleton<DispatcherManager>
    {
        internal void SetChanged(DirtyDataDispatcher dispatcher)
        {
            if (!m_DirtyDispatchers.Contains(dispatcher)) m_DirtyDispatchers.Add(dispatcher);
        }

        public void ManualSync()
        {   
            if (m_DirtyDispatchers.Count < 1) return;
            
            foreach (DirtyDataDispatcher curr in m_DirtyDispatchers)
            {
                curr.ManualSync();
            }
            m_DirtyDispatchers.Clear();
        }

        HashSet<DirtyDataDispatcher> m_DirtyDispatchers = new HashSet<DirtyDataDispatcher>();
    }
}
